package com.gpframework.module.module.domain.req;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gpframework.common.utils.DateUtils;
import com.gpframework.common.utils.StringUtils;
import com.gpframework.module.base.domain.req.BaseReq;
import com.gpframework.module.module.domain.GpColorFastness;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * @ClassName GpColorFastnessReq
 * @Author gpframework
 * @Date 2023-12-11
 * @Version 1.0.0
 * @Description 列表查询信息体
 */
@Data
@ToString
@EqualsAndHashCode
@NoArgsConstructor
@Accessors(chain = true)
public class GpColorFastnessReq extends BaseReq {
    private static final long serialVersionUID = 1L;

         @ApiModelProperty("${column.columnComment}")
     private Long id;
     @ApiModelProperty("品牌id")
     private String brandId;
     @ApiModelProperty("品牌名称")
     private String brandName;
     @ApiModelProperty("订单号")
     private String sn;
     @ApiModelProperty("检测时间")
     private Date checkTime;
     @ApiModelProperty("检测时间（开始）")
     private Date checkStartTime;
     @ApiModelProperty("检测时间（结束）")
     private Date checkEndTime;
     @ApiModelProperty("批号")
     private String batchNo;
     @ApiModelProperty("产品基础表id")
     private Long produceProductId;
     @ApiModelProperty("产品名")
     private String productName;
     @ApiModelProperty("颜色")
     private String colour;
     @ApiModelProperty("干擦评定")
     private String dryWipe;
     @ApiModelProperty("湿擦评定")
     private String wetWipe;
     @ApiModelProperty("水洗评定")
     private String wash;
     @ApiModelProperty("官方检测结果")
     private String officialTestResults;
     @ApiModelProperty("检测人id")
     private Long checkId;
     @ApiModelProperty("检测人名称")
     private String checkName;
     @ApiModelProperty("排序")
     private Integer sort;
     @ApiModelProperty("备注")
     private String remarks;
     @ApiModelProperty("创建者")
     private String createBy;
     @ApiModelProperty("创建时间")
     private Date createTime;
     @ApiModelProperty("更新者")
     private String updateBy;
     @ApiModelProperty("更新时间")
     private Date updateTime;
     @ApiModelProperty("删除标记;0未删除。1已删除。")
     private Integer delStatus;
    @ApiModelProperty("查询条件（订单号/客户名）")
    private String searchName;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date searchDate;
    /** 操作人名称 */
    @ApiModelProperty("操作人名称")
    private String operatorName;
    /** 操作人编号 */
    @ApiModelProperty("操作人编号")
    private String operatorNum;
    /**审批人名称 */
    @ApiModelProperty("审批人名称")
    private String examinName;

    /**检测机构名称 */
    @ApiModelProperty("检测机构名称")
    private String institutionName;

    /**
    * @Description 生成查询wrapper
    * @Author greatplan@qq.com
    * @Date 2020-11-04 16:04
    * @Param [lqw]
    * @Param [isVO] 是否vo查询体，true的话走的是mapper.xml里面的查询语句，不过查询语法还是mybatis-plus，主要用于某些关联查询出一些非数据表字段
    * @Return void
    */
    public void generatorQuery(QueryWrapper<GpColorFastness> lqw,boolean isVo) {
        String alias = "";
        if (isVo) {
            alias = "gp.";
            lqw.eq(alias+"del_status",0);
            lqw.orderByDesc(alias+"create_time");
        }
        if (this.getId() != null){
        lqw.eq(alias+"id" ,this.getId());
        }
        if (StringUtils.isNotBlank(this.getBrandId())){
        lqw.eq(alias+"brand_id" ,this.getBrandId());
        }
        if (StringUtils.isNotBlank(this.getBrandName())){
            lqw.like(alias+"brand_name",this.getBrandName());
        }
        if (StringUtils.isNotBlank(this.getSn())){
        lqw.eq(alias+"sn" ,this.getSn());
        }
        if (this.getCheckTime() != null){
        lqw.eq(alias+"check_time" ,this.getCheckTime());
        }
         if (this.getCheckStartTime() != null && this.getCheckEndTime() != null){
            lqw.between(alias+"check_time" ,this.getCheckStartTime(), this.getCheckEndTime());
        }
        if (StringUtils.isNotBlank(this.getBatchNo())){
        lqw.like(alias+"batch_no" ,this.getBatchNo());
        }
        if (this.getProduceProductId() != null){
        lqw.eq(alias+"produce_product_id" ,this.getProduceProductId());
        }
        if (StringUtils.isNotBlank(this.getProductName())){
            lqw.like(alias+"product_name",this.getProductName());
        }
        if (StringUtils.isNotBlank(this.getColour())){
        lqw.like(alias+"colour" ,this.getColour());
        }
        if (StringUtils.isNotBlank(this.getDryWipe())){
        lqw.eq(alias+"dry_wipe" ,this.getDryWipe());
        }
        if (StringUtils.isNotBlank(this.getWetWipe())){
        lqw.eq(alias+"wet_wipe" ,this.getWetWipe());
        }
        if (StringUtils.isNotBlank(this.getWash())){
        lqw.eq(alias+"wash" ,this.getWash());
        }
        if (StringUtils.isNotBlank(this.getOfficialTestResults())){
        lqw.eq(alias+"official_test_results" ,this.getOfficialTestResults());
        }
        if (this.getCheckId() != null){
        lqw.eq(alias+"check_id" ,this.getCheckId());
        }
        if (StringUtils.isNotBlank(this.getCheckName())){
            lqw.like(alias+"check_name",this.getCheckName());
        }
        if (this.getSort() != null){
        lqw.eq(alias+"sort" ,this.getSort());
        }
        if (StringUtils.isNotBlank(this.getRemarks())){
        lqw.eq(alias+"remarks" ,this.getRemarks());
        }
        if (StringUtils.isNotBlank(this.getCreateBy())){
        lqw.eq(alias+"create_by" ,this.getCreateBy());
        }
        if (this.getCreateTime() != null){
        lqw.eq(alias+"create_time" ,this.getCreateTime());
        }
        if (StringUtils.isNotBlank(this.getUpdateBy())){
        lqw.eq(alias+"update_by" ,this.getUpdateBy());
        }
        if (this.getUpdateTime() != null){
        lqw.eq(alias+"update_time" ,this.getUpdateTime());
        }
        if (this.getDelStatus() != null){
        lqw.eq(alias+"del_status" ,this.getDelStatus());
        }
        if (StringUtils.isNotBlank(this.getSearchName())) {
            lqw.and(wrapper -> wrapper.like("gp.sn", this.getSearchName()).or().like("gp.product_name", this.getSearchName()).or().like("gp.colour", this.getSearchName()));
        }
        if (this.getSearchDate() != null) {
            lqw.apply("DATE_FORMAT(gp.create_time, '%Y-%m-%d') = '" + DateUtils.dateTime(this.getSearchDate()) + "'");
        }
    }
}
